package com.rjpacket.supernews.app.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;

import java.util.List;

/**
 * Created by aaa on 15-3-10.
 */

/**
 * 所有的ViewPager 的Adapter
 */
public class ViewPagerCommonAdapter extends FragmentPagerAdapter {
    //传入一个List的集合，里面放的是要展现的所有的fragment
    private List<Fragment> fragments;

    public ViewPagerCommonAdapter(FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int i) {
        Fragment fragment = null;
        if (fragments != null) {
            fragment = fragments.get(i);
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
